const express = require('express');
const UserController = require('../controllers/user.controller');
const auth = require('../middleware/auth');

const router = express.Router();

// 公开路由
router.post('/register', UserController.register);
router.post('/login', UserController.login);

// 需要认证的路由
router.get('/profile', auth, UserController.getProfile);
router.put('/profile', auth, UserController.updateProfile);
router.put('/profile/password', auth, UserController.updatePassword);

// 用户收货地址路由
router.get('/profile/addresses', auth, UserController.getUserAddresses);
router.post('/profile/addresses', auth, UserController.addAddress);
router.put('/profile/addresses/:addressId', auth, UserController.updateAddress);
router.delete('/profile/addresses/:addressId', auth, UserController.deleteAddress);
router.patch('/profile/addresses/:addressId/set-default', auth, UserController.setDefaultAddress);

module.exports = router; 